home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_09
/
1109114a
< prev
next >
Wrap
Text File
|
1993-07-11
|
695b
|
31 lines
/* array6.c: Ragged arrays */
#include <stdio.h>
#include <string.h>
main()
{
char *strings[] = {"now","is","the","time"};
size_t n = sizeof strings / sizeof strings[0];
int i;
/* Print from ragged array */
for (i = 0; i < n; ++i)
printf("String %d == \"%s\","
"\tsize == %d,"
"\tlength == %d\n",
i,strings[i],
sizeof strings[i],
strlen(strings[i]));
return 0;
}
/* Output
String 0 == "now", size == 2, length == 3
String 1 == "is", size == 2, length == 2
String 2 == "the", size == 2, length == 3
String 3 == "time", size == 2, length == 4
*/